{% stylesheet %}
.collection_detail_default .collection_img{
    width: 100%;
    height: 400px;
}
.collection_detail_default .collection_img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.collection_detail_default .collection_detail {
    padding: 0 0 20px;
    text-align: center;
}
.collection_detail_default .collection_bom_detail{
    text-align: center;
}

.collection_detail_default .collection_top_bar {
    display: flex;
    display: -webkit-flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0 3rem;
    flex-direction: column;
}

.collection_detail_default .sort_by {
    display: flex;
    display: -webkit-flex;
    align-items: center;
    margin-top: 30px;
}

.collection_detail_default .sort_by span {
    margin-right: 15px;
}

.collection_detail_default .sort_by select {
    height: 40px;
    border: 1px solid #d4d4d4;
    cursor: pointer;
}

.collection_detail_default .collection_content ul {
    display: grid;
    grid-row-gap: 30px;
    grid-column-gap: 40px;
    grid-template-columns: repeat(4, calc(25% - 22.5px));
}

.collection_detail_default .collection_content li {
    list-style-type: none;
    line-height: 1;
}

.collection_detail_default .collection_content .product_pic {
    margin-bottom: 12px;

    position: relative;
}


.collection_detail_default .collection_content .product_pic .product_img {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    width: 100%;
}

.collection_detail_default .collection_content .product_pic img {
    max-width: 100%;
}

.collection_detail_default .collection_content .block_product_name {
    margin-bottom: 5px;
    line-height: 1.5;
}
.collection_detail_default .collection_content .product_price {
    font-weight: bold;
}

.collection_detail_default .collection_content .product_oldprice {
    color: #888;
    text-decoration: line-through;
    margin-left: 5px;
    font-weight: normal;
}




@media (max-width: 768px) {
    .collection_detail_default .collection_content ul{
        grid-template-columns: repeat(3, calc(33.3333% - 20px));
    }
}
@media (max-width: 767px) {
    .collection_detail_default .collection_content ul {
        grid-row-gap: 30px;
        grid-column-gap: 15px;
        grid-template-columns: repeat(2, calc(50% - 7.5px));
    }
    .collection_detail_default .collection_content_more {
        margin-top: 30px;
    }
    .collection_detail_default .collection_content .product_pic{
        margin-bottom: 20px;
    }
}

@media screen and (min-width: 768px) and (max-width: 1200px) {
    .block_collection_list .collection_product_pc_4 ul {
        grid-template-columns: repeat(3, calc(33.33% - 20px));
    }
}

{% endstylesheet %}
{% if section.page_id %}
{% get_collection_by_id id = { section.page_id } %}
{% assign collection = collection %}
{% assign paginate = paginate %}
{% assign theme_config = section.theme_config %}
{% endif %}

{% assign defaultImageEmpty = 'empty.png' | public_asset_abs_url %}

<div class="collection_detail_default container_wrapper" id="collection_detail">
  <div class="plugin-container-header"></div>

	<h1 class="title">{{ collection.title | default : lang.collections.detail.all_products }}</h1>
	{% if section.settings.show_top and collection.top_descript != "" %}
	<div class="collection_detail mo-editor-reset">{{ collection.top_descript }}</div>
	{% endif %}
	<div class="collection_top_bar">
		<div class="product_num">{{ collection.all_products_count }} {{ lang.collections.detail.products }}</div>
		<div class="sort_by">
			<span>{{ lang.general.sort_by }}</span>
			<select class="form-control" id='sort_by_select'>
				{% assign sort_by = collection.sort_by | default: collection.sort_by  | lstrip %}
				{% for option in collection.sort_options %}
				<option value="{{option.value}}" {% if option.value == sort_by %}selected="selected" {% endif %}>{{ option.name }}</option>
				{% endfor %}
			</select>
		</div>
	</div>
	{% if collection.products | size %}
	<div class="collection_content collection_product_wap_2">
		<ul>
			{% for product in collection.products %}
			{% include collection_product , product : product , collection_handle:collection.handle  %}
			{% endfor %}
		</ul>
		{% include pagination ,{ paginate : paginate } %}

	</div>
	{% else %}
	{% include empty ,{text:lang.general.empty }%}

	{% endif %}

	{% if section.settings.show_bottom %}
	<div class="collection_bom_detail mo-editor-reset" style="overflow: hidden;">
		{{collection.bottom_descript}}
	</div>
	{% endif %}
	<div class="plugin-container-footer"></div>
    

	
</div>

<script type="text/javascript">
	console.log({{ collection.products | json }})
	console.log({{ collection | json }})

	$(function(){
		$('#sort_by_select').change(function (params) {
		    const sort_by = $(this).val();
            location.href = moi.setUrlParams(location.href, { "sort_by": sort_by || "","page": 1});
	    })
	})
	
</script>

{% schema %}
{
  "tag": "",
  "class": "collection_detail",
  "is_global": false,
  "name": {
    "zh_CN": "专辑详情"
  },
  "max_blocks": "20",
  "settings": [
    {
      "type": "card_header",
      "label": {
        "zh_CN": "设置"
      }
    },
    {
      "type": "card_switch",
      "label": {
        "zh_CN": "头部描述"
      },
      "default": true,
      "id": "show_top"
    },
    {
      "type": "card_switch",
      "label": {
        "zh_CN": "底部描述"
      },
      "default": true,
      "id": "show_bottom"
    }
  ],
  "blocks": [],
  "default": {
    "settings": {
      "show_img": true,
      "show_top": true,
      "show_bottom": true
    },
    "blocks": []
  }
}
{% endschema %}